<?php
$dis_id=4;
include("../../inc/conn.inc");
include("../islogin.php");

if($_POST['act_xg']){
 $_POST["b_title"]=delwords($_POST["b_title"]);
  $_POST["b_keyword"]=delwords($_POST["b_keyword"]);
    $_POST["b_info"]=delwords($_POST["b_info"]);
	$_POST["b_pinpai"]=delwords($_POST["b_pinpai"]);
	$_POST["b_xinghao"]=delwords($_POST["b_xinghao"]);
	$_POST["b_cailiao"]=delwords($_POST["b_cailiao"]);
$c_rs_1=mysql_query("select * from catalog where id='$_POST[catalog_1]'");
$c_row_1=mysql_fetch_array($c_rs_1);
$c_rs_2=mysql_query("select * from catalog where id='$_POST[catalog_2]'");
$c_row_2=mysql_fetch_array($c_rs_2);
$c_rs_3=mysql_query("select * from catalog where id='$_POST[catalog_3]'");
$c_row_3=mysql_fetch_array($c_rs_3);


$catalog_1=($_POST[catalog_1])?$_POST[catalog_1]:0;
$catalog_2=($_POST[catalog_2])?$_POST[catalog_2]:0;
$catalog_3=($_POST[catalog_3])?$_POST[catalog_3]:0;

mysql_query("update buy set b_title='$_POST[b_title]',catalog_id1='$catalog_1',catalog_1='$c_row_1[cat_name]',catalog_id2='$catalog_2',catalog_2='$c_row_2[cat_name]',catalog_id3='$catalog_3',catalog_3='$c_row_3[cat_name]',b_keyword='$_POST[b_keyword]',b_info='$_POST[b_info]',picture='$_POST[picture]',b_pinpai='$_POST[b_pinpai]',b_xinghao='$_POST[b_xinghao]',b_guige='$_POST[b_guige]',b_price='$_POST[b_price]$_POST[b_price2]',b_baozhuang='$_POST[b_baozhuang]',b_shuliang='$_POST[b_shuliang]',b_cailiao='$_POST[b_cailiao]',b_changdi='$_POST[b_changdi]',b_jhtime='$_POST[b_jhtime]',b_renzheng='$_POST[b_renzheng]',b_crz='$_POST[b_crz]',b_minorder='$_POST[b_minorder]$_POST[b_minorder2]',b_paytype='$_POST[b_paytype]',b_endtime='".date("Y-m-d H:m:s",strtotime($_POST[b_addtime]."+".$_POST[b_endtime]."day"))."',b_cl='0',b_xj='1' where id='".$_POST['iid']."'");


echo "<script>alert('编辑成功');location='index.php';</script>";
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>会员中心-三帝贸易网</title>
<link href="../css/css.css" rel="stylesheet" type="text/css" />
</head>
<script type="text/javascript" src="../js/left.js" charset="gb2312"></script>
<script type="text/javascript" src="../js/catalog.js" charset="gb2312"></script>
<body>
<div id="mian">
<?php include("../inc/top.php");?>
<div class="top1"><span>您当前位置：<a href="../index.php" class="dh">会员助手</a> &gt;&gt; 供应信息 &gt;&gt; 产品管理</span></div>
<div class="left">
<?php include("../inc/left.php");?>
</div>
<div class="right">
<TABLE cellSpacing="0" cellPadding="0" width="100%" border="0">
   <TR>
     <TD height="40" bgcolor="#EFF6FF" style="font-size:18px;font-weight:bold;padding-left:8px;">编辑求购信息</TD>
   </TR>
</TABLE>
<br>
<?php
$rs=mysql_query("select * from buy where id='".$_GET['xg_id']."' and member_id='".$_COOKIE['user_id']."'");
$row=mysql_fetch_array($rs);
if(!$row['id']){
echo "<script>alert('非法提交');location='index.php'</script>";
}
?>
      <TABLE width="100%" border="0" cellpadding="0" cellSpacing="1" bgcolor="#C1DCF5">
        <TBODY>
        <form method="post" action="" name="form1"  onSubmit="return checkform()">
          <TR>
            <td width="17%" height="25" align="center" bgcolor="#EFF6FF">产品名称<font color="#FF0000">*</font></td>
            <TD width="83%" bgcolor="#F9F9F9" style="padding-left:4px;"><input name="b_title" id="b_title" value="<?=$row[b_title]?>" type="text" size="50" maxlength="120"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">产品目录<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;line-height:35px;">

<select name="catalog_1" id="catalog_1" onChange="changelocation(document.form1.catalog_1.options[document.form1.catalog_1.selectedIndex].value)">
	<option value="">--选择大类--</option>   
  <?php
$rrs=mysql_query("select * from catalog where cat_id=0 order by id asc");    
while($rrow=mysql_fetch_array($rrs)){   
  ?>     
   <option value="<?=$rrow[id]?>" <?php if($row[catalog_id1]==$rrow[id]){echo "selected";}?>><?=$rrow[cat_name]?></option>   
 <?php }?></select>&nbsp;<select name="catalog_2" id="catalog_2" onFocus="changelocation(document.form1.catalog_1.options[document.form1.catalog_1.selectedIndex].value)">
					  <option value="">--选择二级分类--</option>
					  <?php 
					    $rrs2=mysql_query("select * from catalog where id='".$row['catalog_id2']."'");
						while($rrow2=mysql_fetch_array($rrs2)){
					  ?><option value="<?=$rrow2['id']?>" selected><?=$rrow2['cat_name']?></option>
					  <?php }?>
                      </select>&nbsp;<select name="catalog_3" id="catalog_3" onFocus="changelocation2(document.form1.catalog_2.options[document.form1.catalog_2.selectedIndex].value)">   
                        <option   value=""   selected>--选择三级分类--</option>
						<?php 
					    $rrs2=mysql_query("select * from catalog where id='".$row['catalog_id3']."'");
						while($rrow2=mysql_fetch_array($rrs2)){
					  ?><option value="<?=$rrow2['id']?>" selected><?=$rrow2['cat_name']?></option>
					  <?php }?>
                      </select></TD>
          </TR>
		  <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">产品有效期<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><SELECT name="b_endtime">
                <OPTION value="360" <?php if(round(((strtotime($row[b_endtime])-strtotime($row[b_addtime]))/86400))==360){echo "selected";}?>>1年</OPTION>
                <OPTION value="180" <?php if(round(((strtotime($row[b_endtime])-strtotime($row[b_addtime]))/86400))==180){echo "selected";}?>>6月</OPTION>
                <OPTION value="90" <?php if(round(((strtotime($row[b_endtime])-strtotime($row[b_addtime]))/86400))==90){echo "selected";}?>>3月</OPTION>
                <OPTION value="30" <?php if(round(((strtotime($row[b_endtime])-strtotime($row[b_addtime]))/86400))==30){echo "selected";}?>>1月</OPTION>
                <OPTION value="15" <?php if(round(((strtotime($row[b_endtime])-strtotime($row[b_addtime]))/86400))==15){echo "selected";}?>>15天</OPTION>
                <OPTION value="7" <?php if(round(((strtotime($row[b_endtime])-strtotime($row[b_addtime]))/86400))==7){echo "selected";}?>>7天</OPTION>
              </SELECT><input type="hidden" name="b_addtime" value="<?=$row[b_addtime]?>"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">产品关键字<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="b_keyword"  type="text" value="<?=$row['b_keyword']?>" size="60" maxlength="500"></TD>
          </TR>		  
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">产品描述<font color="#FF0000">*</font></td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><textarea name="b_info" cols="70" rows="15"><?=$row[b_info]?></textarea></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">产品图片</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><?php if($row[picture]){?><img src="/upfile/<?=$row[picture]?>" width="140" height="104" border="0" /><br /><?php }?><input name="picture" type="text" value="<?=$row[picture]?>" size="35" maxlength="100">&nbsp;&nbsp;<input name="button" type="button" onClick="window.open ('../upfile.php', 'newwindow', 'height=50, width=400, top=250, left=250, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')" value="上传图片">(图片限制140*104)</TD>
          </TR>
		  <TR>
            <td height="25" colspan="2" align="left" bgcolor="#EFF6FF"><STRONG>产品属性</STRONG></td>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">产品品牌</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="b_pinpai" value="<?=$row[b_pinpai]?>" type="text" size="30" maxlength="50"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">产品型号</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="b_xinghao" value="<?=$row[b_xinghao]?>" type="text" size="30" maxlength="50"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">产品规格</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="b_guige" value="<?=$row[b_guige]?>" type="text" size="30" maxlength="50"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">参考价格</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="b_price" value="<?=$row[b_price]?>" type="text" size="30" maxlength="50">
              <select name="b_price2">
                <OPTION value="">--请选择--</OPTION>
                <OPTION value="/台">/台</OPTION>
                <OPTION value="/粒">/粒</OPTION>
                <OPTION value="/座">/座</OPTION>
                <OPTION value="/辆">/辆</OPTION>
                <OPTION value="/只">/只</OPTION>
                <OPTION value="/支">/支</OPTION>
                <OPTION value="/枝">/枝</OPTION>
                <OPTION value="/架">/架</OPTION>
                <OPTION value="/头">/头</OPTION>
                <OPTION value="/张">/张</OPTION>
                <OPTION value="/块">/块</OPTION>
                <OPTION value="/片">/片</OPTION>
                <OPTION value="/匹">/匹</OPTION>
                <OPTION value="/件">/件</OPTION>
                <OPTION value="/根">/根</OPTION>
                <OPTION value="/条">/条</OPTION>
                <OPTION value="/把">/把</OPTION>
                <OPTION value="/卷">/卷</OPTION>
                <OPTION value="/副">/副</OPTION>
                <OPTION value="/幅">/幅</OPTION>
                <OPTION value="/双">/双</OPTION>
                <OPTION value="/一打">/一打</OPTION>
                <OPTION value="/份">/份</OPTION>
                <OPTION value="/套">/套</OPTION>
                <OPTION value="/棵">/棵</OPTION>
                <OPTION value="/箱">/箱</OPTION>
                <OPTION value="/袋">/袋</OPTION>
                <OPTION value="/盒">/盒</OPTION>
                <OPTION value="/包">/包</OPTION>
                <OPTION value="/捆">/捆</OPTION>
                <OPTION value="/筐">/筐</OPTION>
                <OPTION value="/瓶（罐）">/瓶（罐）</OPTION>
                <OPTION value="/毫米">/毫米</OPTION>
                <OPTION value="/厘米">/厘米</OPTION>
                <OPTION value="/米">/米</OPTION>
                <OPTION value="/千米">/千米</OPTION>
                <OPTION value="/英寸">/英寸</OPTION>
                <OPTION value="/英尺">/英尺</OPTION>
                <OPTION value="/加仑(英)">/加仑 (英)</OPTION>
                <OPTION value="/加仑(美)">/加仑 (美)</OPTION>
                <OPTION value="/克">/克</OPTION>
                <OPTION value="/千克">/千克</OPTION>
                <OPTION value="/磅">/磅</OPTION>
                <OPTION value="/公吨">/公吨</OPTION>
                <OPTION value="/吨(英)">/吨 (英)</OPTION>
                <OPTION value="/吨(美)">/吨 (美)</OPTION>
                <OPTION value="/毫升">/毫升</OPTION>
                <OPTION value="/公升">/公升</OPTION>
                <OPTION value="/盎司">/盎司</OPTION>
                <OPTION value="/夸脱">/夸脱</OPTION>
                <OPTION value="/品脱(英)">/品脱(英)</OPTION>
                <OPTION value="/品脱(美)">/品脱(美)</OPTION>
                <OPTION value="/码">/码</OPTION>
                <OPTION value="/平方英尺">/平方英尺</OPTION>
                <OPTION value="/平方英寸">/平方英寸</OPTION>
                <OPTION value="/平方米">/平方米</OPTION>
                <OPTION value="/平方码">/平方码</OPTION>
                <OPTION value="/立方米">/立方米</OPTION>
              </SELECT></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">产品包装</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="b_baozhuang" value="<?=$row[b_baozhuang]?>" type="text" size="30" maxlength="50"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">产品材料</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="b_cailiao" value="<?=$row[b_cailiao]?>" type="text" size="30" maxlength="50"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">产品产地</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="b_changdi" value="<?=$row[b_changdi]?>" type="text" size="30" maxlength="50"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">产品交货期</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="b_jhtime" value="<?=$row[b_jhtime]?>" type="text" size="30" maxlength="50"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">产品认证</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="b_renzheng" value="<?=$row[b_renzheng]?>" type="text" size="30" maxlength="50">
            (如:CE认证) </TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">企业认证</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="b_crz" value="<?=$row[b_crz]?>" type="text" size="30" maxlength="50"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">采购数量</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="b_minorder" value="<?=$row[b_minorder]?>" type="text" size="30" maxlength="50">
              <select name="b_minorder2">
                <OPTION value="">--请选择--</OPTION>
                <OPTION value="/台">/台</OPTION>
                <OPTION value="/粒">/粒</OPTION>
                <OPTION value="/座">/座</OPTION>
                <OPTION value="/辆">/辆</OPTION>
                <OPTION value="/只">/只</OPTION>
                <OPTION value="/支">/支</OPTION>
                <OPTION value="/枝">/枝</OPTION>
                <OPTION value="/架">/架</OPTION>
                <OPTION value="/头">/头</OPTION>
                <OPTION value="/张">/张</OPTION>
                <OPTION value="/块">/块</OPTION>
                <OPTION value="/片">/片</OPTION>
                <OPTION value="/匹">/匹</OPTION>
                <OPTION value="/件">/件</OPTION>
                <OPTION value="/根">/根</OPTION>
                <OPTION value="/条">/条</OPTION>
                <OPTION value="/把">/把</OPTION>
                <OPTION value="/卷">/卷</OPTION>
                <OPTION value="/副">/副</OPTION>
                <OPTION value="/幅">/幅</OPTION>
                <OPTION value="/双">/双</OPTION>
                <OPTION value="/一打">/一打</OPTION>
                <OPTION value="/份">/份</OPTION>
                <OPTION value="/套">/套</OPTION>
                <OPTION value="/棵">/棵</OPTION>
                <OPTION value="/箱">/箱</OPTION>
                <OPTION value="/袋">/袋</OPTION>
                <OPTION value="/盒">/盒</OPTION>
                <OPTION value="/包">/包</OPTION>
                <OPTION value="/捆">/捆</OPTION>
                <OPTION value="/筐">/筐</OPTION>
                <OPTION value="/瓶（罐）">/瓶（罐）</OPTION>
                <OPTION value="/毫米">/毫米</OPTION>
                <OPTION value="/厘米">/厘米</OPTION>
                <OPTION value="/米">/米</OPTION>
                <OPTION value="/千米">/千米</OPTION>
                <OPTION value="/英寸">/英寸</OPTION>
                <OPTION value="/英尺">/英尺</OPTION>
                <OPTION value="/加仑(英)">/加仑 (英)</OPTION>
                <OPTION value="/加仑(美)">/加仑 (美)</OPTION>
                <OPTION value="/克">/克</OPTION>
                <OPTION value="/千克">/千克</OPTION>
                <OPTION value="/磅">/磅</OPTION>
                <OPTION value="/公吨">/公吨</OPTION>
                <OPTION value="/吨(英)">/吨 (英)</OPTION>
                <OPTION value="/吨(美)">/吨 (美)</OPTION>
                <OPTION value="/毫升">/毫升</OPTION>
                <OPTION value="/公升">/公升</OPTION>
                <OPTION value="/盎司">/盎司</OPTION>
                <OPTION value="/夸脱">/夸脱</OPTION>
                <OPTION value="/品脱(英)">/品脱(英)</OPTION>
                <OPTION value="/品脱(美)">/品脱(美)</OPTION>
                <OPTION value="/码">/码</OPTION>
                <OPTION value="/平方英尺">/平方英尺</OPTION>
                <OPTION value="/平方英寸">/平方英寸</OPTION>
                <OPTION value="/平方米">/平方米</OPTION>
                <OPTION value="/平方码">/平方码</OPTION>
                <OPTION value="/立方米">/立方米</OPTION>
              </SELECT></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">付款方式</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input name="b_paytype" type="text" value="<?=$row[b_paytype]?>" size="30" maxlength="50"></TD>
          </TR>
          <TR>
            <td height="25" align="center" bgcolor="#EFF6FF">&nbsp;</td>
            <TD bgcolor="#F9F9F9" style="padding-left:4px;"><input type="submit" value="提交"><input type="hidden" name="iid" value="<?=$row['id']?>">
        <INPUT type="hidden" value="ok" name="act_xg"></TD>
          </TR>
 </form>                
</TABLE>
</div>
<div class="onl"></div>
<?php include("../inc/foot.php");
?>
</div>
</body>
</html>
<script language="javascript">
function $(id){
return document.getElementById(id);
}
function checkform(){
   if($("b_title").value==""){
      alert("产品名称不能为空");
      $("b_title").focus();
      return false;
   }
   if($("catalog_1").value==""){
      alert("请选择产品目录");
      $("catalog_1").focus();
      return false;
   }
   if($("catalog_2").value==""){
      alert("请选择二级目录");
      $("catalog_2").focus();
      return false;
   }

   if($("b_endtime").value==""){
      alert("请选择有效期");
      $("b_endtime").focus();
      return false;
   }   
   if($("b_keyword").value==""){
      alert("产品关键字不能为空");
      $("b_keyword").focus();
      return false;
   }   
   if($("b_info").value==""){
      alert("产品描述不能为空");
      $("b_info").focus();
      return false;
   }   

}
</script>